111<template lang="html">
  <section class="components-index_date_picker">
    <div
      class="datePicker-event"
      :class="{ active: currentIndex === 0 }"
      @click="selectDay(0)"
    >
      <span class="event-text">
        <em>special</em>
        <em>activities</em>
      </span>
    </div>
    <div class="datePicker-dateList-container">
      <ul class="dateList">
        <li
          v-for="(date, index) in dates"
          :class="{ active: index + 1 == currentIndex }"
          @click="selectDay(index + 1)"
        >
          <span class="contentWrap">
            <em class="number">{{date.month >= 10 ? date.month : '0' + date.month}}.{{date.date >= 10 ?date.date : '0'+date.date}}</em>
            <em class="text">{{ index + 1 == currentIndex ? date.dayString.en:date.dayString.en.slice(0,3) }}</em>
          </span>
       </li>
      </ul>
    </div>
  </section>
</template>

<script>
export default {
  props: {
    dates: {
      type: Array,
      require: true
    }
  },
  data(){
    return {
      scrollerEle: null
    }
  },
  computed: {
    currentIndex(){
      return this.$store.state.indexData.currentIndex
    }
  },
  watch: {
    currentIndex(val){
      if(val >= 6){
        this.scrollerEle.scrollLeft = 999
      } else if(val <= 2){
        this.scrollerEle.scrollLeft = 0
      }
    }
  },
  mounted(){
    this.scrollerEle = document.querySelector('.datePicker-dateList-container')
    this.$emit('eSelectDay', this.currentIndex)
  },
  methods: {
    selectDay(idx){
      this.$store.dispatch('setCurrentIndex', idx)
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../css/config";
$event-width: 110px;
$picker-height: 75px;
.components-index_date_picker{
  position: relative;
  width: 100%;
  height: 95px;
  background-color: $common-bg;
  box-sizing: border-box;
  padding-left: $event-width;
  .datePicker-event{
    position: absolute;
    top: 0;
    left: 0;
    width: $event-width;
    // height: 100%;
    height: $picker-height;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    &.active{
      .event-text{
        width: 100%;
        height: 100%;
        border-radius: 0;
        transition: all 0.2s ease-in-out;
      }
    }
    .event-text{
      display: block;
      width: $picker-height;
      height: $picker-height;
      border-radius: 100%;
      overflow: hidden;
      background: $common-red;
      color: #fff;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      em:nth-child(1){
        display: block;
        font-size: 14px;
        padding-bottom: 5px;
      }
      em:nth-child(2){
        display: block;
        font-size: 16px;
      }
    }
  }
  .datePicker-dateList-container{
    display: block;
    width: 100%;
    height: 100%;
    overflow-x: scroll;
    .dateList{
      display: inline-block;
      min-width: 100%;
      height: $picker-height;
      white-space: nowrap;
      box-sizing: border-box;
      border: 1Px solid rgba(104, 105, 102, 0.5);
      border-top: 0;
      &>li{
        display: inline-block;
        width: 100px;
        height: 100%;
        color: #fff;
        .contentWrap{
          width: 100%;
          height: 100%;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-content: center;
          .number{
            display: block;
            text-align: center;
            font-size: 24px;
            padding-bottom: 5px;
          }
          .text{
            display: block;
            text-align: center;
            font-size: 14px;
          }
        }
        &.active{
          color: $common-red;
          background-color: #202020;
          border-bottom: 5px solid #ff505f;
        }
      }
    }
  }
}
</style>
